<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.users.User,
                com.scalar.chiptrack.users.UserGroup,
                com.scalar.chiptrack.commons.SessionKeys,
                com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/jsp/operations/operations.jsp"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script language="JavaScript">

function searchOrderList(theForm)
{
    var err = '';
    if( ( document.scheduling.manufacturingPartNo.value == -1 ) || ( document.scheduling.manufacturingPartNo.value == -2 ) )
    {
		err = err + '<li> Please select a valid Product Name';
    }

	if( err != '' )
    {
		var pa = document.getElementById( "errors" );
        pa.innerHTML = err;
    	return false;
	}

	theForm.action.value = "SearchOrders";
	theForm.submit();
}

/*function GetAllProducts()
{
	newWindow = window.open('loadProducts.do','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=500,height=600,left=300,top=30,resizable=no');
  	newWindow.focus();
}

function assignProduct(passedValue)
{
	document.scheduling.marketingPartNo.value = passedValue;
	window.focus();
}*/

function submitPage()
{
	document.scheduling.action.value = "ScheduleOrder";
    document.scheduling.submit();
}

function openScheduling(partNo, lineItemNo, salesOrderId)
{
  	newWindow = window.open('scheduling.do?action=ShowInventory&mfgPartNo='+partNo+'&lineItemNo='+lineItemNo+'&salesOrderId='+salesOrderId,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,top=0,left=0,resizable=yes');
	newWindow.focus();
}

function scheduleLineItem (partNo, lineItemNo, salesOrderId, requestedDate, quantity)
{
  	newWindow = window.open('scheduling.do?action=reschedule&mfgPartNo='+partNo+'&lineItemNo='+lineItemNo+'&salesOrderId='+salesOrderId+'&requestedDate='+requestedDate+'&quantity='+quantity,'optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,top=0,left=0,resizable=yes');
	newWindow.focus();
}

function openSalesOrder(salesOrderId)
{
	newWindow = window.open('order.do?action=printOrder&revisedDate=false&salesOrderId=' + salesOrderId,'pendingOrdersView','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=600,height=600,left=100,top=50,resizable=yes');
    newWindow.focus();
}

</script>
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/operations/operations_menu.jsp" %></TD>
<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>

<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<!-- from here your body starts -->
<center><span class="NArialW">Order Scheduling</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
<html:form name="scheduling" method="post" action="/scheduling" type="com.scalar.chiptrack.sales.forms.OrdersForm" onsubmit="return searchOrderList(document.scheduling);">

 <table border="0" width="90%" align=right>
   <tr><td colspan=5>
    <chiptrack:info styleClass="NArialL" />
    <chiptrack:errors styleClass="NArialL" /> <!-- Added by Rohan on July 20th 2004-->
    <chiptrack:messages type="error" styleClass="NArialL" />
   </td></tr>
   <tr><td colspan=5><table border='0' bordercolor='#FFFFFF'><tr><td class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></td></tr></table></td></tr>
    <tr>
      <td width="35%"><font class="NArialL">Product Name<br>(<bean:message key = "label.mfgPartNumber" />)</font></td>
      <td width="15%"><font class="NArialL">
            <html:select name="scheduling" property="manufacturingPartNo" styleClass="txfield">
                <html:option value="0">All Products</html:option>
                <html:options collection="productList" property="value" labelProperty="label"/>
           </html:select>
      </td>
      <td width="25%" align="right"><font class="NArialL">Customer</font></td>
      <td width="15%"><html:select name="scheduling" property="customerId" styleClass="txfield">
            <html:options collection="customerList" property="value" labelProperty="label"/>
        </html:select></td>
      <td><font class="NArialL"></font></td>
    </tr>
    <tr>
       <!-- added by prabhanjan on 28th october 2003 for providing additional search criterion on sales order number -->
      <td width="25%"><font class="NArialL">Sales Order #</font></td>
      <td width="15%"><html:text name="scheduling" property="salesOrderNo" styleClass="txfield" size="20" /></td>

      <td width="15%" align="right"><font class="NArialL" >Year</font></td>
      <td width="15%"><font class="NArialL">
        <%-- <html:text name="ordersForm" property="year" size="5" maxlength="4" styleClass="txfield" />  --%>
        <html:select name="ordersForm" property="year" styleClass="txfield">
            <html:option value="">-Select-</html:option>
            <html:options collection="years" property="value" labelProperty="label" />
        </html:select>
      </td>
      <!-- till here prabhanjan -->
    </tr>
    <!-- Added nu Prabhanjan on 16th November 2003.These values are used to submit the form again with same values. -->
    <tr><td colspan=5 width="25%">
      <!--logic : present parameter="manufacturingPartNo"  >
      <input type="hidden" name="prevManufacturingPartNo" value="<%= request.getParameter("manufacturingPartNo")%>">
      < / logic : present >
      < logic : present parameter="customerId" >
      <input type="hidden" name="prevCustomerId" value="<%= request.getParameter("customerId")%>">
      < / logic : present >
      < logic : present parameter="salesOrderNo" >
      <input type="hidden" name="prevSalesOrderNo" value="<%= request.getParameter("salesOrderNo")%>">
      < / logic : present -->
      </td>
    </tr>

    <tr><td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
    <tr>
      <td colspan=5 align=center>
         <!-- modified by prabhanjan on 28th october 2003 -->
         <!-- <a href="javascript:searchOrderList(document.scheduling);"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17"></a> -->
         <input type=image src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" border=0 onMouseOver="window.status='Click to Search for Orders';return true" onMouseOut="window.status='';return true" title="Click here to Search for Orders">
         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
         <a href="javascript:document.scheduling.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onMouseOver="window.status='Click to Reset';return true" onMouseOut="window.status='';return true" title="Click here to Reset"></a>
      </td>
    </tr>
   <tr><td colsapn=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></str>
   <tr><td colspan=5 valign="top">
   <logic:equal name="showList" value="TRUE">
   <table border="1" width="100%" bordercolor="#FFFFFF" align=center cellspacing='0'>
    <tr>
       <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sales Order #</font></td>
       <td width="4%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Line Item</font></td>
       <td width="19%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Customer Name</font></td>
       <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Ordering Part #</font></td>
       <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.customerPartNumber" /></font></td>
       <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity</font></td>
       <!--td width="6%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Unit Price</font></td -->
       <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Booking Date</font></td>
       <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Req'd Dock Date</font></td>
       <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sugg Ship Date</font></td>
       <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Schedule Date</font></td>
    </tr>

    <%
        String bgColor[] = {"#DEE1E2", "#FFFFEE"};
        int bgcount = 0;
    %>
    <logic:iterate id="LineItem" name="lineItemList">
    <% bgcount = bgcount + 1; %>
    <tr><td colspan=5><html:hidden name="LineItem" property="lineItemId" /></td></tr>
    <tr>
       <td width="10%" align="center" bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL">
       <!-- Modified by Prabhanjan on 31st October 2003 -->
       <A href="<%=chipTracContext%>/approveOrder.do?salesOrderId=<bean:write name="LineItem" property="salesOrderId"/>&salesOrderNo=<bean:write name="LineItem" property="salesOrderNo"/>&requestOrderSchedulingSearch=true" onMouseOver="window.status='Click to see the Complete Order';return true" onMouseOut="window.status='';return true"><bean:write name="LineItem" property="salesOrderNo" /></A></font></td>

       <td width="4%" align="center"  bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="lineItemNo" /></font></td>
       <td width="19%" align="left" bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL">
                <bean:write name="LineItem" property="customerName" /></font></td>

       <td width="15%" align="center" bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="manufacturingPartNo" /></font></td>
       <td width="15%" align="center" bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="customerPartNo" /></font></td>
       <td width="8%" align="right"   bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="qtyAsString" />&nbsp;&nbsp;</font></td>
       <!-- td width="6%" align="right"   bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="unitPriceAsString"/>&nbsp;&nbsp;</font></td -->
       <td width="8%" align="center"  bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="bookingDate" />&nbsp;&nbsp;
       <td width="8%" align="center"  bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="requestDate" />&nbsp;&nbsp;
       </font></td>

       <td width="8%" align="center"  bgcolor= '<%=bgColor[bgcount%2]%>'>
        <font class="NArialL">

                <logic:notEqual name="LineItem" property="suggScheduleDate" value="">
                    <logic:notMatch name="LineItem" property="suggScheduleDate" value="/">
                        <A href="javascript:scheduleLineItem ('<bean:write name="LineItem" property="manufacturingPartNo"/>', '<bean:write name="LineItem" property="lineItemNo" />', '<bean:write name="LineItem" property="salesOrderId"/>', '<bean:write name="LineItem" property="requestDate"/>', '<bean:write name="LineItem" property="quantity"/>' );" onMouseOver="window.status='Click to Schedule the Order';return true" onMouseOut="window.status='';return true">
                        Schedule</A>&nbsp;&nbsp;
                    </logic:notMatch>

                    <logic:match name="LineItem" property="suggScheduleDate" value="/">
                        <A href="javascript:openScheduling ('<bean:write name="LineItem" property="manufacturingPartNo"/>', '<bean:write name="LineItem" property="lineItemNo" />', '<bean:write name="LineItem" property="salesOrderId"/>' );" onMouseOver="window.status='Click to Open the Scheduling';return true" onMouseOut="window.status='';return true">
                        <bean:write name="LineItem" property="suggScheduleDate"/></A>&nbsp;&nbsp;
                    </logic:match>
                </logic:notEqual>

                <logic:equal name="LineItem" property="suggScheduleDate" value="">
                     <A href="javascript:scheduleLineItem ('<bean:write name="LineItem" property="manufacturingPartNo"/>', '<bean:write name="LineItem" property="lineItemNo" />', '<bean:write name="LineItem" property="salesOrderId"/>', '<bean:write name="LineItem" property="requestDate"/>', '<bean:write name="LineItem" property="quantity"/>' );" onMouseOver="window.status='Click to Schedule the Order';return true" onMouseOut="window.status='';return true">
                        Schedule</A>&nbsp;&nbsp;
                </logic:equal>

        </font>
       </td>

       <td width="8%" align="center"  bgcolor= '<%=bgColor[bgcount%2]%>'><font class="NArialL"><bean:write name="LineItem" property="scheduleDate"/></font></td>

    </tr>
      </logic:iterate>
    <!--tr><td colspan='9' align=center><a href="javascript:submitPage();"><img src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border=0></a>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="javascript:document.scheduling.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border=0></a>
    </td></tr-->

    <tr><td colspan='9'><IMG height=30 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></td></tr>
    </table>

    </logic:equal>
    </td></tr>

</table>
<input type="hidden" name="action" value="">
<!-- added by Prabhanjan on 22 November 2003 -->
<input type="hidden" name="fromOrderScheduling" value="true"/>
</html:form>


<!-- till here -->

<!-- till here -->
<BR><BR><BR>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TBODY>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>